home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / include / assert.h < prev    next >
C/C++ Source or Header  |  1996-01-30  |  2KB  |  57 lines

  1. /* This is file assert.h */
  2. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  3. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  4. ** Rochester NH, 03867-2954, USA.
  5. */
  6.  
  7. /* This may look like C code, but it is really -*- C++ -*- */
  8. /* 
  9. Copyright (C) 1988 Free Software Foundation
  10.  
  11. This file is part of GNU CC.
  12.  
  13. GNU CC is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY.  No author or distributor
  15. accepts responsibility to anyone for the consequences of using it
  16. or for whether it serves any particular purpose or works at all,
  17. unless he says so in writing.  Refer to the GNU CC General Public
  18. License for full details.
  19.  
  20. Everyone is granted permission to copy, modify and redistribute
  21. GNU CC, but only under the conditions described in the
  22. GNU CC General Public License.   A copy of this license is
  23. supposed to have been given to you along with GNU CC so you
  24. can know your rights and responsibilities.  It should be in a
  25. file named COPYING.  Among other things, the copyright notice
  26. and this notice must be preserved on all copies.  
  27. */
  28.  
  29. /* Allow this file to be included multiple times
  30.    with different settings of NDEBUG.  */
  31. #undef assert
  32. #undef assertval
  33.  
  34. #ifdef NDEBUG
  35. #define assert(ignore)
  36. #define assertval(ex)  (ex)
  37. #else
  38.  
  39. #ifdef __cplusplus
  40. extern "C" void __eprintf (char*, int, char*);          /* Defined in gnulib */
  41. extern "C" volatile void   abort(void);
  42. #else
  43. void __eprintf (char*, int, char*);              /* Defined in gnulib */
  44. volatile void   abort(void);
  45. #endif
  46.  
  47. #define assert(ex) \
  48.         ((ex) ? 1 : \
  49.               (__eprintf("Failed assertion " #ex " at line %d of `%s'.\n", \
  50.                __LINE__, __FILE__), abort (), 0))
  51. #define assertval(ex) \
  52.         ((ex) ? (ex) : \
  53.               (__eprintf("Failed assertion " #ex " at line %d of `%s'.\n", \
  54.                __LINE__, __FILE__), abort (), 0))
  55.  
  56. #endif /* NDEBUG */
  57.